<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Article extends MY_Controller {
	
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		
		$this->tab = 'platform';
	}
	
	
	private function post_data(){
		$ptime 		= $this->input->post('ptime');
		
		$data = array(
				'nid'=>$this->input->post('nid'),
				'title'=>$this->input->post('title'),
				'ptime'=>$ptime?strtotime($ptime):time(),
				'author'=>$this->input->post('author'),
				'forder'=>$this->input->post('forder'),
				'content'=>trim($this->input->post('content')),
				'is_show'=>intval($this->input->post('is_show')),
				'is_recommend'=>intval($this->input->post('is_recommend')),
				'seo_keyword'=>trim($this->input->post('seo_keyword')),
			);
		  		
		if($data['nid'] == '' || $data['nid'] == 0){
			$ret['msg'] = '所属类别不能为空';
		}elseif($data['title'] == ''){
			$ret['msg'] = '标题不能为空';
		}elseif($data['seo_keyword'] == ''){
			$ret['msg'] = 'SEO内链关键词不能为空';
		}elseif($data['content'] == ''){
			$ret['msg'] = '内容编辑不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
				
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_ARTICLE_IMG, ARTICLE_IMG,'article_');
		}
				
  		$data['thumbnail'] 	= $thumbnail;
  		
  		return $data;
	}
	
	function add_view(){
		$this->load->helper(array('form'));
		$this->load->model('Site_model');
  		$vdata['site_array'] = $this->Site_model->get_site_title_array();
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'site_news';
		
		$this->load->view("/sys_admin/site/article_add", $vdata);
	}
	
	
	
	
	function add(){
		
		$data = $this->post_data();
  		$data['add_time'] = time();
  		$data['addip'] = $this->js->get_ip();
		
  		$this->load->model('article_model');
  		$article_id = $this->article_model->add($data);
  		
		$this->load->model('log_model');$this->log_model->add_log('[添加][新闻资讯内容]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function view($article_id){
		$this->load->model('article_model');
  		$article = $this->article_model->get_article_obj($article_id);
  		$vdata['article'] = $article;
  		$this->load->view("/sys_admin/site/article_view", $vdata);
	}
	
	function edit_view($article_id){
		$this->load->helper(array('form'));
		$this->load->model('article_model');
  		$article = $this->article_model->get_article_obj($article_id);
  		$vdata['article'] = $article;
  		$this->load->model('Site_model');
  		$vdata['site_array'] = $this->Site_model->get_site_search_array();
  		//清除缓存列表
			$index_gonggao_key = 'rsh_index_gonggao_list'.$article['nid'];
			$this->mycache->delete($index_gonggao_key);
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'site_news';
		
  		$this->load->view("/sys_admin/site/article_edit", $vdata);
	}
	
	
	
	function edit(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_data();
		
		$bthumbnail 		= $this->input->post('bthumbnail');
		$data['thumbnail']= $data['thumbnail']?$data['thumbnail']:$bthumbnail;
				  	
  		$this->load->model('article_model');
  		$article_id = $this->article_model->update($id, $data);
  		
		$this->load->model('log_model');$this->log_model->add_log('[修改][新闻资讯内容]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function zhs_articlelist(){
		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$nid 				= $this->input->get('nid');
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		if($nid != 0){
			$data['where']['nid'] = $nid;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('article_model');
		$vdata = $this->article_model->get_new_article_list($data);
		
		$vdata['article_show'] 			= $this->article_model->arrays('article_show');//用途
		
		$this->load->model('site_model');
		$sdata = $this->site_model->get_site_search_array();
		$vdata['site_array'] = empty($sdata)? array():$sdata;
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/article/zhs_articlelist/'.$nid.'?title='.$title;
		$config['total_rows'] = $vdata['article_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
		
		$vdata['title'] 	= $title;
		$vdata['nid'] 		= $nid;
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'site_news';
		
		$this->load->view('/sys_admin/site/article_list', $vdata);
	}
	
	function remove(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('article_model');
		echo  $this->article_model->update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][新闻资讯内容]');
	}
	
}
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Article extends MY_Controller {
    
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		
		$this->tab = 'platform';
	}
	
	
	private function post_data(){
		$ptime 		= $this->input->post('ptime');
		
		$data = array(
				'nid'=>$this->input->post('nid'),
				'title'=>$this->input->post('title'),
				'ptime'=>$ptime?strtotime($ptime):time(),
				'author'=>$this->input->post('author'),
				'forder'=>$this->input->post('forder'),
				'content'=>trim($this->input->post('content')),
				'is_show'=>intval($this->input->post('is_show')),
				'is_recommend'=>intval($this->input->post('is_recommend')),
				'seo_keyword'=>trim($this->input->post('seo_keyword')),
			);
		  		
		if($data['nid'] == '' || $data['nid'] == 0){
			$ret['msg'] = '所属类别不能为空';
		}elseif($data['title'] == ''){
			$ret['msg'] = '标题不能为空';
		}elseif($data['seo_keyword'] == ''){
			$ret['msg'] = 'SEO内链关键词不能为空';
		}elseif($data['content'] == ''){
			$ret['msg'] = '内容编辑不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
				
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_ARTICLE_IMG, ARTICLE_IMG,'article_');
		}
				
  		$data['thumbnail'] 	= $thumbnail;
  		
  		return $data;
	}
	
	function add_view(){
		$this->load->helper(array('form'));
		$this->load->model('Site_model');
  		$vdata['site_array'] = $this->Site_model->get_site_title_array();
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'site_news';
		
		$this->load->view("/sys_admin/site/article_add", $vdata);
	}
	
	
	
	
	function add(){
		
		$data = $this->post_data();
  		$data['add_time'] = time();
  		$data['addip'] = $this->js->get_ip();
		
  		$this->load->model('article_model');
  		$article_id = $this->article_model->add($data);
  		
		$this->load->model('log_model');$this->log_model->add_log('[添加][新闻资讯内容]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function view($article_id){
		$this->load->model('article_model');
  		$article = $this->article_model->get_article_obj($article_id);
  		$vdata['article'] = $article;
  		$this->load->view("/sys_admin/site/article_view", $vdata);
	}
	
	function edit_view($article_id){
		$this->load->helper(array('form'));
		$this->load->model('article_model');
  		$article = $this->article_model->get_article_obj($article_id);
  		$vdata['article'] = $article;
  		$this->load->model('Site_model');
  		$vdata['site_array'] = $this->Site_model->get_site_search_array();
  		//清除缓存列表
			$index_gonggao_key = 'rsh_index_gonggao_list'.$article['nid'];
			$this->mycache->delete($index_gonggao_key);
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'site_news';
		
  		$this->load->view("/sys_admin/site/article_edit", $vdata);
	}
	
	
	
	function edit(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_data();
		
		$bthumbnail 		= $this->input->post('bthumbnail');
		$data['thumbnail']= $data['thumbnail']?$data['thumbnail']:$bthumbnail;
				  	
  		$this->load->model('article_model');
  		$article_id = $this->article_model->update($id, $data);
  		
		$this->load->model('log_model');$this->log_model->add_log('[修改][新闻资讯内容]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function zhs_articlelist(){
		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$nid 				= $this->input->get('nid');
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		if($nid != 0){
			$data['where']['nid'] = $nid;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('article_model');
		$vdata = $this->article_model->get_new_article_list($data);
		
		$vdata['article_show'] 			= $this->article_model->arrays('article_show');//用途
		
		$this->load->model('site_model');
		$sdata = $this->site_model->get_site_search_array();
		$vdata['site_array'] = empty($sdata)? array():$sdata;
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/article/zhs_articlelist/'.$nid.'?title='.$title;
		$config['total_rows'] = $vdata['article_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
		
		$vdata['title'] 	= $title;
		$vdata['nid'] 		= $nid;
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'site_news';
		
		$this->load->view('/sys_admin/site/article_list', $vdata);
	}
	
	function remove(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('article_model');
		echo  $this->article_model->update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][新闻资讯内容]');
	}
	
}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
